<%@ page contentType="text/html; charset=UTF-8" language="java"%>
<%@ page import="com.hzqy.commons.utils.ConstantUtils" %>
<%@ page import="com.hzqy.web.vo.PmsUserVo" %>
<%@ taglib prefix="limits" uri="/WEB-INF/tld/limits.tld"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>阀值管理</title>
<link rel="stylesheet" type="text/css"	href="../../static/js/themes/defalut.css">
<link rel="stylesheet" type="text/css"	href="../../static/js/themes/public.css">
<link rel="stylesheet" type="text/css"	href="../../static/js/themes/ddspstyle.css">
<link rel="stylesheet" type="text/css"	href="../../static/js/themes/default/easyui.css">
<link rel="stylesheet" type="text/css"	href="../../static/js/themes/icon.css">
<link rel="stylesheet" type="text/css"	href="../../static/js/WdatePicker/skin/WdatePicker.css">

<script type="text/javascript" src="../../static/js/jquery.min.js"></script>
<script type="text/javascript" src="../../static/js/jquery.easyui.min.js"></script>
<script type="text/javascript" src="../../static/js/locale/easyui-lang-zh_CN.js"></script>
<script type="text/javascript" src="../../static/js/index.js"></script>
<script type="text/javascript" src="../../static/js/WdatePicker/WdatePicker.js"></script>

<%
String []nonceObj=ConstantUtils.getNonceObject();
PmsUserVo userVo=(PmsUserVo)session.getAttribute(ConstantUtils.SESSION_USER);
String roleType="0";
if(userVo!=null){
	roleType=userVo.getRoleIds();
}
%>

<script type="text/javascript">
		var queryParams;
		function EasyuiDatagrid() {
			$("#easyui-datagrid").datagrid({
				url: '../../industry/threshold/selectThresholdList.do',
				nowrap: true,
				striped: true,
				border: false,
				fit: true,
				rownumbers:true,
				queryParams: getGueryParams(),
				columns: [[
					{field:'id',checkbox:true},
					{field:'f_itv_id',title:'ID',align:'center',width:50},
					{field:'f_itv_customName',title:'行业客户',align:'center',width:150},
					{field:'f_itv_thesholdHW',title:'华为阀值',align:'center',width:150},
					{field:'f_itv_thesholdZTE',title:'中兴阀值',align:'center',width:150},
					{field:'f_itv_useHWSize',title:'华为已用',align:'center',width:60,
						formatter:function(value,row,index) {
							return value;
						}	
					},
					{field:'f_itv_useZTESize',title:'中兴已用',align:'center',width:60,
						formatter:function(value,row,index) {
							return value;
						}	
					},
					{field:'f_itv_status',title:'状态',align:'center',width:80,
						formatter:function(value,row,index) {
							var status = "未知";
							if(value==1){
								status="生效";
							} else if(value==2||value==16||value==14){
								status="无效";
							}
							return status;
						}	
					},
					{field:'f_itv_cdate',title:'添加时间',align:'center',width:150,
						formatter:function(value,row,index) {
							var str = "";
							if(value!=null)
								str = value.substring(0,19);
							return str;
						}	
					},
					{field:'_parentId',title:'操作',align:'center',width:450,
						formatter:function(value,row,index){
							str ="";
							str= '<a class="easyui-linkbutton l-btn l-btn-plain" iconCls="icon-ok" href="javascript:void(0);" plain="true" onclick="onClickBtnDelete(\''+row.f_itv_id+'\',\''+row.f_itv_status+'\');" ><span class="l-btn-left"><span class="l-btn-text icon-remove l-btn-icon-left">删除</span></span></a>';
							str+= '<a class="easyui-linkbutton l-btn l-btn-plain" iconCls="icon-ok" href="javascript:void(0);" plain="true" onclick="edit(\''+row.f_itv_id+'\');" ><span class="l-btn-left"><span class="l-btn-text icon-edit l-btn-icon-left">修改</span></span></a>';
							//str+= '<a class="easyui-linkbutton l-btn l-btn-plain" iconCls="icon-ok" href="javascript:void(0);" plain="true" onclick="info(\''+row.f_itv_id+'\');" ><span class="l-btn-left"><span class="l-btn-text icon-edit l-btn-icon-left">详情</span></span></a>';
					    	return str;
				    	}
					}
				]],
				singleSelect:false,
				pagination:true,
				pageList:[10,20,30,40,50],
				pageSize:10,
				toolbar: '#toolbar',
				
				onExpandRow: function(index,row){
				
				},
				onSelect: function(rowIndex,rowData) {
					
				},
				onUnselect: function(rowIndex,rowData) {
					
				},
				onCheckAll: function(rowIndex,rowData) {
					
				},
				onUncheckAll: function(rowIndex,rowData) {
				
				},
				onLoadSuccess: function(data) {
					if(data.total==-1) {
						$.messager.defaults={ok:"确定",cancel:"取消"};
						$.messager.confirm('提示', '用户尚未登录,请登录', function(r){
						if (r){
						    window.parent.location.href='/login.do';
						    return false;
						}});
					}
				}
			});
		}
	
		function getGueryParams(){
			var orgId=0;
			if($("#f_itv_customId").val()==""){
				
			}else{
				orgId=$("#f_itv_customId").val();
			}
			return {
				f_itv_status:$("#f_itv_status").val(),
				f_itv_customId:orgId,
				sctt_endDate:$("#sctt_endDate").val(),
				sctt_startDate:$("#sctt_startDate").val()
			};
		}
		
		$(function(){
			$.ajax({
				url:"../../pms/org_list.do",
				success:function(data) {
					data = JSON.parse(data);
					var str = "";
					for(var i=0;i<data.length;i++) {
						str+='<option value="'+data[i].id+'">'+data[i].name+'</option>';
					}
					$("#f_itv_customId").append(str);
					
					$("#orgSpan").append($("#f_itv_customId").clone(true));
				}
			});
			new EasyuiDatagrid();
			gotoSearch = function(){
				$("#easyui-datagrid").datagrid('reload',getGueryParams());
			};
			
			onClickBtnDelete = function(id,_status){
				$.messager.confirm('确定删除节目','确定删除节目么?',function(r){
					if(r){
						var url='../../industry/threshold/deleteThreshold.do?f_itv_id='+id;
						app_ajax(url,
						'',
						function(msg){
							if(msg.success) {
									alert("删除成功!");
								if (checkAjaxRequestValidity(msg)) {
									gotoSearch($('#easyui-treegrid'));
								}
							} else {
								alert("删除异常，请联系管理员");
								if($.isFunction(window.showMessager)){
									window.showMessager(msg.resultTitle,msg.result);
								}
							}
						}
						);
					}
				});
			};
			
			$("#chooseOption1").on("change", function(){
				if($(this).val() == 1){
					$("#chooseOption2").show();
				} else {
					$("#chooseOption2").hide();
				}
			});
			
			
		});
		function cleanThreshold(){
			$.messager.confirm('确定清空阀值节目','确定清空阀值么?',function(r){
				if(r){
					var url='../../industry/threshold/clearThreshold.do';
					app_ajax(url,
					'',
					function(msg){
						if(msg.success) {
								alert("删除成功!"+msg.result);
							if (checkAjaxRequestValidity(msg)) {
								gotoSearch($('#easyui-treegrid'));
							}
						} else {
							alert("删除异常，请联系管理员。"+msg.result);
							if($.isFunction(window.showMessager)){
								window.showMessager(msg.resultTitle,msg.result);
							}
						}
					}
					);
				}
			});
		}
		function SubgridTabOnSelect(title,index){
			setTimeout(function(){
				$("#easyui-datagrid").datagrid('fixDetailRowHeight',index);
			},300);
			setTimeout(function(){
				$("#easyui-datagrid").datagrid('fixDetailRowHeight',index);
			},3000);
	    }
		
		function load(){
			$(".datagrid-row-expander datagrid-row-expand").attr("display","none"); 
		}
		
		function _resert(){
			$("#f_cc_name").val("");
			$("#f_cc_status").val("");
		}
		
		function onpress(){
			var event=arguments.callee.caller.arguments[0]||window.event;//消除浏览器差异
	   		  	if (event.keyCode == 13){  
	      			gotoSearch($('#easyui-treegrid'));
	    		}
		}
		
		function edit(id){
			openDialog($("#dlg"),'threshold_update.jsp?f_itv_id='+id);
		}

		function info(id){
			openDialog($('#dlg'),'threshold_info.jsp?f_itv_id='+id);
		}
		function showHistroyMessage(id){
			openDialog($('#base_histroy'),'c2_basic_history_list.jsp?f_cc_id='+id);
		}
		function add(){
			openDialog($('#dlg'),'threshold_add.jsp');
		}
		function bind(id) {
			openDialog($('#org_list'),'../behavior_control/org_update.jsp?idField=f_itv_customId&nameField=f_itv_customName');
		}
		
		function resert(){
			$("#f_itv_customName").val("");
			$("#f_itv_customId").val("");
		}
	</script>
</head>
<body onload="load();" style="width: 100%;">
	<input type="hidden" id="sessionId" value="${pageContext.session.id}" />
	<table id="easyui-datagrid" title="节目列表"></table>
	<div id="toolbar" class="easyui_datagrid_toolbar" style="">
		<div class="easyuiSearch">
			<form onsubmit="return false;" method="post">
				<table cellspacing="0" cellpadding="0" width="90%">
					<tr>
						<td align="left" width="7%">状态:</td>
						<td align="left" width="16%">
							<select id="f_itv_status" name="f_itv_status">
									<option value="0">请选择</option>
									<option value="1">生效</option>
									<option value="2">无效</option>
							</select>
						</td>
						<td align="left" width="7%">
							操作日期：
						</td>
						<td align="left" width="15%">
							<input id="sctt_startDate" name="sctt_startDate" type="text" onClick="WdatePicker()" style="width: 150px;" value="" class="yl_inp yw_name" />	
						</td>
						<td align="left" width="5%">
							&nbsp至
						</td>
						<td align="left" >
							<input id="sctt_endDate" name="sctt_endDate" type="text" onClick="WdatePicker()" style="width: 150px;" value="" class="yl_inp yw_name" />
						</td>
					
					</tr>
					<tr>
						<td  align="left" width="10%">
							行业客户:
						</td>
						<td align="left" width="30%">
							<input name="f_itv_customName" id="f_itv_customName" readonly="readonly"	style="width: 150px;" value="" class="yl_inp yw_name" />
							<input name="f_itv_customId" id="f_itv_customId" type="hidden" value="" />  
							<input name="status" id="status" type="hidden" value="nochange" />  
							<!-- <select id="f_cc_companyid" name="f_cc_companyid" style="width: 150px;">
							</select> -->
							<!-- <span id="f_cc_companyid_tip" class="tip"></span> -->
							<a id="12" class="easyui-linkbutton" data-options="iconCls:'icon-ok'" href="javascript:void(0);" onclick="resert()">空选</a>
							<a id="12" class="easyui-linkbutton" data-options="iconCls:'icon-ok'" href="javascript:void(0);"
								onclick="bind();">选择</a>
						</td>
						<td>
						<a href="javascript:void(0);" class="easyui-linkbutton"
									data-options="iconCls:'icon-search', plain:true"
									onclick="gotoSearch($('#easyui-datagrid'))">查询</a>
						</td>
						<td>
							<a href="javascript:void(0);" class="easyui-linkbutton"
									data-options="iconCls:'icon-add', plain:true"
									onclick="add()">新增</a>
						</td>
						<td width="10%">
							<a href="javascript:void(0);" class="easyui-linkbutton"
									data-options="iconCls:'icon-add', plain:true"
									onclick="cleanThreshold()">清空阀值</a>
						</td>
						<td>
						</td>
						<td>
						</td>
						<td>
						</td>
					</tr>
				</table>
			</form>
		</div>
		<div style="margin-bottom: 5px">
		</div>
	</div>
	<div id="dlg" class="easyui-dialog"
		style="width: 950px; height: 600px; padding-top: 0px;"
		data-options="title:'节目管理', iconCls:'icon-save',modal:true,closed:true,buttons:'#dlg_buttons'">
		<iframe scrolling="auto" frameborder="0"
			style="width: 100%; height: 99%;"></iframe>
	</div>
	<div id="org_list" class="easyui-dialog"
		style="width: 800px; height: 500px; padding-top: 0px;"
		data-options="title:'客户选择', iconCls:'icon-save',modal:true,closed:true,buttons:'#dlg_buttons'">
		<iframe scrolling="auto" frameborder="0"
			style="width: 100%; height: 99%;"></iframe>
	</div>
	
	
</body>
</html>